﻿using System;
using System.Collections.Generic;
#if DEBUG
using System.Diagnostics;
#endif // #if DEBUG
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using FRL.DebtChased.Repository;
using FRL.DebtChased.Repository.ViewModels;
using FRL.DebtChased.Website;

namespace WebApplication.Finance
{

	/// <summary>
	/// Declaration of ClientAlertsDefault
	/// </summary>
	public partial class ClientAlertsDefault : System.Web.UI.Page
	{

		/////////////////////////////////////////////////////////////
		// Event handlers

		protected void Page_Load(object sender, EventArgs e)
		{

			// If this is a postback...
			if (this.IsPostBack)
			{

			}
			else
			{

			}

		}

		protected void butRevert_Click( object sender, EventArgs e )
		{

			// Reload the page
			this.Reload();

		}

		protected void butSave_Click( object sender, EventArgs e )
		{

			// Gte the user=id
			MySession mySession = MySession.BindMySession();
			int iUserId = mySession.UserID;
#if DEBUG
			if (iUserId == 0)
				iUserId = 1;
#endif // #if DEBUG

			// Update the model
			ClientAlertsModel model = clientAlertsCtrl.ContextModel;

			// Declare an entities object
			string strError = null;
			using (DebtChasedEntities ent = new DebtChasedEntities())
			{

				// Save model to store
				strError = model.Set(ent, iUserId);

			}

			// If that worked...
			if (strError == null)
				this.Reload();
			else
				(this.Page.Master as FinanceMaster).ErrorMessage = strError;

		}

	}

}